package org.example.baizhi.service;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.example.baizhi.annotaions.RedisCache;
import org.example.baizhi.dao.UserDAO;
import org.example.baizhi.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.DigestUtils;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Set;
import java.util.UUID;

@Service
@Transactional
public class UserServiceImpl implements UserService{

    @Autowired
    private UserDAO userDAO;

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    @RedisCache(value1 = "user mould cache")
    public List<User> queryAll() {
        return userDAO.findAll();
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    @RedisCache(value1 = "user findOne cache")
    public User find(String id) {
        return userDAO.find(id);
    }


    @Override
    public void save(User user) {
        user.setId(UUID.randomUUID().toString());
        userDAO.save(user);
    }



}
